<?php

namespace app\index\controller;

use \PhpOffice\PhpSpreadsheet\Spreadsheet;
use \PhpOffice\PhpSpreadsheet\Writer\Xlsx;

/**
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/09/05
 * Time: 16:13
 */
class Test extends Base
{
    public function test2()
    {
        $url = [
            0 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            1 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            2 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            3 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            4 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            5 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            6 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ],
            7 => [
                'title' => "北环分部-20楼-C160",
                'url' => 'http://mdxundian.oss-cn-zhangjiakou.aliyuncs.com/xcx_code/upload_202004071531028804.jpg'
            ]
        ];

        $t = new \app\common\controller\Pdf();
        $url = $t->gen_ws_pdf($url);
        echo $url;
    }

    public function test3()
    {
        $date1 = '2020-01-01';
        $date2 = '2020-04-21';

        $r = get_time_diff_date($date1, $date2);

        halt($r);
    }

    public function test4()
    {
        $maps = [];
        $maps[] = ['id', '=', 1];
        $ws_detail = model('work_station')->get_detail($maps);

        for ($i = 1; $i <= 1000; $i++) {
            $temp = [];
            $temp['regionid'] = $ws_detail['regionid'];
            $temp['number'] = $ws_detail['number'];
            $temp['work_type'] = $ws_detail['work_type'];
            $temp['measure'] = $ws_detail['measure'];
            $temp['price'] = $ws_detail['price'];
            $temp['suggest_person_num'] = $ws_detail['suggest_person_num'];
            $temp['window_direction'] = $ws_detail['window_direction'];
            $temp['is_indoor_air'] = $ws_detail['is_indoor_air'];
            $temp['ws_pic'] = $ws_detail['ws_pic'];
            $temp['company_pic'] = $ws_detail['company_pic'];
            $temp['company_name'] = $ws_detail['company_name'];
            $temp['company_person'] = $ws_detail['company_person'];
            $temp['company_tel'] = $ws_detail['company_tel'];
            $temp['company_work_preson'] = $ws_detail['company_work_preson'];
            $temp['company_out_time'] = $ws_detail['company_out_time'];
            $temp['company_in_time'] = $ws_detail['company_in_time'];
            $temp['company_introduce'] = $ws_detail['company_introduce'];
            $temp['company_business'] = $ws_detail['company_business'];
            $temp['is_show_company'] = $ws_detail['is_show_company'];
            $temp['wechat_mini_code_pic'] = $ws_detail['wechat_mini_code_pic'];

            $ws_data[] = $temp;
        }
        $r = model('work_station')->insertAll($ws_data);

        halt($r);
    }

    public function test5()
    {
        $openid = 'oEg6q5Uv4R44nOMDtgI7XrtmgQyM';
        $maps = [];
        $maps[] = ['openid', '=', $openid];
        $maps[] = ['status', '=', 1];
        $maps[] = ['enable', '=', 1];
        $u_detail = model('user')->get_detail($maps, 'id');
        halt($u_detail);
    }
}
